﻿// Inner Fire 游戏引擎库
// 渲染项目类-Image渲染项目
//
// Copyright (c) 2024 by 尔西大帝. All rights reserved.
//
// 用于UI中的Image渲染项目
//
// Author: 尔西大帝
// Email: 2670613871@qq.com
// Created: 2024-12-21

#pragma once

#include <dx/ui/ui_render_item.h>
#include <dx/ui/ui_instanced_data.h>
#include <sprite_pack.h>

using namespace ikit;

namespace ifire::dx {

struct DxImageDesc {
  UIWidget Widget;
  SpriteElement* pElement;
};

class DxImage : public UIRenderItem {
public:
  DxImage(const DxImageDesc& desc);
  DxImage(const DxImage& lhs) = delete;
  DxImage& operator=(const DxImage& lhs) = delete;
  ~DxImage() = default;

  // 对缓冲区进行更新
  void Update(XMFLOAT2 client_size, UIInstancedData& data);
  void SetPosition(DirectX::XMFLOAT2 position);

public:
  SpriteElement* mElement;
};

using DxImagePtr = std::unique_ptr<DxImage>;
} // namespace ifire::dx